//
//  CollectionViewController.m
//  Korea
//
//  Created by 杨东奇 on 15/9/9.
//  Copyright (c) 2015年 KoreaGo. All rights reserved.
//

#import "CollectionViewController.h"
#import "CollectionViewCell.h"
#import "Header.h"
#import "testViewController.h"
@interface CollectionViewController ()<UICollectionViewDataSource, UICollectionViewDelegate>
@property (nonatomic ,strong) NSMutableArray *dataArray;
@property (nonatomic ,strong) UICollectionView *collection;
@end

@implementation CollectionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"收藏";
    self.dataArray = @[@"dd"];
    if (self.dataArray.count == 0) {
        UIImageView *backImage = [[UIImageView alloc] initWithFrame:self.view.bounds];
        backImage.image = [UIImage imageNamed:@"收藏提示.png"];
        [self.view addSubview:backImage];
    }else{
        
        UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc] init];
        flow.itemSize = CGSizeMake(self.view.frame.size.width, self.view.frame.size.height / 3);
        flow.minimumInteritemSpacing = 0;
        flow.minimumLineSpacing = 0;
        
        self.collection = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height - 49) collectionViewLayout:flow];
        _collection.dataSource = self;
        _collection.delegate = self;
        [self.collection registerClass:[CollectionViewCell class] forCellWithReuseIdentifier:@"reuse"];
        [self.view addSubview:self.collection];
    }
}

- (NSInteger) collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 10;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuse" forIndexPath:indexPath];
    cell.titleLabel.tag = 20000;
    cell.blur.tag = 20001;
    cell.blur.userInteractionEnabled = YES;
    cell.titleLabel.text = @"我们都是美食的俘虏";
    cell.highlighted = YES;
    
    return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"sdsd");
    
    testViewController *test = [[testViewController alloc] init];
    [self.navigationController pushViewController:test animated:YES];
    
}


- (BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtIndexPath:(NSIndexPath *)indexPath{
    CollectionViewCell *cell = (CollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
    cell.blur.hidden = YES;
    cell.titleLabel.hidden = YES;
    return YES;
}

- (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    CollectionViewCell *cell = (CollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
    cell.blur.hidden = NO;
    cell.titleLabel.hidden = NO;
    return YES;
}
- (void)singleAction{
    
    
    UIView *view = [self.collection viewWithTag:20000];
    UIView *view2 = [self.collection viewWithTag:20001];
    view.hidden = YES;
    view2.hidden = YES;
    NSLog(@"ddddd");
}
- (void)longtouch{
    UIView *view = [self.collection viewWithTag:20000];
    UIView *view2 = [self.collection viewWithTag:20001];
    view.hidden = YES;
    view2.hidden = YES;
    NSLog(@"sdd");
}
@end
